package com.freewater.springboot.demo.ioc.circledependency;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class SimpleAspect {

    @Pointcut("execution(* com.freewater.springboot.demo.ioc.circledependency.*Service.*(..))")
    private void allMethodOfSomeService() {
    }

    @Around("allMethodOfSomeService()")
    public Object someAdvice(ProceedingJoinPoint joinPoint) {
        if (joinPoint != null) {
            try {
                System.out.println("some process before");
                final Object returnVal = joinPoint.proceed();
                System.out.println("some process after");
                return returnVal;
            } catch (Throwable e) {
                throw new RuntimeException(e);
            }
        }
        return null;
    }
}
